#include <iostream>
#include "DenserGraph.h"
#include "SparseGraph.h"
#include "ReadGraph.h"
#include "AdjIteratorTest.h"
#include "Component.h"
#include "Path.h"


int main() {
    srand(time(NULL));
    string fileName1 = "testG1.txt";
    string fileName2 = "testG2.txt";

    //using DenserGraph, testG2
    DenserGraph g1(7, false);
    ReadGraph<DenserGraph> readGraph(g1, fileName2);
    Componment<DenserGraph> componment1(g1);
    cout << "using DenserGraph, testG2 的连通分量 ： " << componment1.count() << endl;


    //using DenserGraph, testG1
    DenserGraph g3(13, false);
    ReadGraph<DenserGraph> readGraph3(g3, fileName1);
    Componment<DenserGraph> componment3(g3);
    cout << "using DenserGraph, testG1 的连通分量 ： " << componment3.count() << endl;


    //using SparseGraph, testG2
    SparseGraph g2(7, false);
    ReadGraph<SparseGraph> readGraph1(g2, fileName2);
    Componment<SparseGraph> componment2(g2);
    cout << "using SparseGraph, testG2 的连通分量 ： " << componment2.count() << endl;


    //using SparseGraph, testG1
    SparseGraph g4(13, false);
    ReadGraph<SparseGraph> readGraph4(g4, fileName1);
    Componment<SparseGraph> componment4(g4);
    cout << "using SparseGraph, testG1 的连通分量 ： " << componment4.count() << endl;

    //test 连通性

    for (int i = 0; i < 10; i++) {
        int a = rand() % 7;
        int b = rand() % 7;
        cout << "a(" << a << ") --- b(" << b << ") is "
             << (componment2.isConnection(a, b) ? "connection!" : "not connection!");
        cout << endl;
    }

    cout << endl;

    //测试路径
    Path<SparseGraph> dfs(g2,0);
    cout << "DFS : ";
    dfs.showPath(6);

    return 0;
}